#pragma once
#include <iostream>
#include <string>
#include <cstdlib>
#include <unordered_map>
#include "../utils/macro.hpp"
enum UserStatus{
	Normal,
	Bankruptcy,//破产
	Hospital,
	Jail
};
class User{
private:
	int id;
	std::string name;
	int money;
	UserStatus status;
	int stopNum;
	int wealthNum;
	int pos;
	int credit;
	char outCh;
	Color outColor;
	std::unordered_map<int, int> ownHouse;
	std::unordered_map<int, int> ownTools;
public:
	User(int id,std::string name,int money,char outCh,Color color):\
		id(id),name(name),money(money),status(Normal),stopNum(0),wealthNum(0),pos(0),credit(0),outCh(outCh),outColor(color){
			ownTools.insert({ToolType::Block,0});
			ownTools.insert({ToolType::Boom,0});
			ownTools.insert({ToolType::Robot,0});
		};
	//every step to run 
	int GetDiceNum(int preset=-1);
	// get char output
	inline char MapChar() const {return this->outCh;};
	inline Color MapColor() const {return this->outColor;};
	// get user msg;
	inline UserStatus GetStatus() const {return status;};
	inline int GetCredit() const {return credit;};
	inline int GetMoney() const {return money;};
	inline int GetPos() const {return pos;};
	inline int GetId() const {return id;};
	inline int GetStopNum() const {return stopNum;};
	inline int GetWealth() const {return wealthNum;};
	inline std::string GetName() const {return name;};
	//set user option
	bool SetPos(int newPos);
	bool SetCredit(int newCredit);
	void SetMoney(int newMoney);
	void SetStatus(UserStatus status){this->status=status;};
	void SetStopNum(int newNum);
	void SetWealthNum(int newNum){
		/* ASSERT(newNum>0); */
		this->wealthNum=newNum;
	};
	std::unordered_map<int, int>* GetToolMsg(){return &this->ownTools;};
	std::unordered_map<int, int>* GetHouseMsg(){return &this->ownHouse;};
	//after one turn
	void OneTurn(){
		if (this->stopNum!=0) {
			this->stopNum--;
		}
		if (status==Hospital||status==Jail) {
			status=Normal;
		}
		if (this->money<0) {
			status=Bankruptcy;
		}
		if (this->wealthNum!=0) {
			this->wealthNum--;
		}
	}
};
